function [x_norm,T] = hmg2norm(x)
%calculate the centroid of each of the points
ctr = mean(x(:,1:2));%calculates a centroid of the set of 2D points
x_ctr = [x(:,1)-ctr(1) x(:,2)-ctr(2)];%shift the center of the points to ctr
m_norm = mean(sqrt(x_ctr(:,1).^2  + x_ctr(:,2).^2));%outputs the mean norm of the points
scale = 1.4142/m_norm;%1.4142 is sqrt(2)!

T = [scale 0 -scale*ctr(1); 0 scale -scale*ctr(2); 0 0 1];
x_norm = (T*x')';

